<?php

/**
 * Character filter form base class.
 *
 * @package    rpgcom
 * @subpackage filter
 * @author     Your name here
 */
abstract class BaseCharacterFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'idUser'       => new sfWidgetFormPropelChoice(array('model' => 'User', 'add_empty' => true)),
      'idChronicle'  => new sfWidgetFormPropelChoice(array('model' => 'Chronicle', 'add_empty' => true)),
      'idStatus'     => new sfWidgetFormPropelChoice(array('model' => 'Status', 'add_empty' => true)),
      'name'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'concept'      => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'idVirtue'     => new sfWidgetFormPropelChoice(array('model' => 'Virtue', 'add_empty' => true)),
      'idVice'       => new sfWidgetFormPropelChoice(array('model' => 'Vice', 'add_empty' => true)),
      'faction'      => new sfWidgetFormFilterInput(),
      'groupName'    => new sfWidgetFormFilterInput(),
      'age'          => new sfWidgetFormFilterInput(),
      'idBloodline'  => new sfWidgetFormPropelChoice(array('model' => 'Bloodline', 'add_empty' => true)),
      'idClan'       => new sfWidgetFormPropelChoice(array('model' => 'Clan', 'add_empty' => true)),
      'idCovenant'   => new sfWidgetFormPropelChoice(array('model' => 'Covenant', 'add_empty' => true)),
      'idAuspice'    => new sfWidgetFormPropelChoice(array('model' => 'Auspice', 'add_empty' => true)),
      'idTribe'      => new sfWidgetFormFilterInput(),
      'idLodge'      => new sfWidgetFormFilterInput(),
      'idAdvantages' => new sfWidgetFormPropelChoice(array('model' => 'Advantages', 'add_empty' => true)),
      'xpTotal'      => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'xpActual'     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'dtIni'        => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'dtEnd'        => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
    ));

    $this->setValidators(array(
      'idUser'       => new sfValidatorPropelChoice(array('required' => false, 'model' => 'User', 'column' => 'idUser')),
      'idChronicle'  => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Chronicle', 'column' => 'idChronicle')),
      'idStatus'     => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Status', 'column' => 'idStatus')),
      'name'         => new sfValidatorPass(array('required' => false)),
      'concept'      => new sfValidatorPass(array('required' => false)),
      'idVirtue'     => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Virtue', 'column' => 'idVirtue')),
      'idVice'       => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Vice', 'column' => 'idVice')),
      'faction'      => new sfValidatorPass(array('required' => false)),
      'groupName'    => new sfValidatorPass(array('required' => false)),
      'age'          => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'idBloodline'  => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Bloodline', 'column' => 'idBloodline')),
      'idClan'       => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Clan', 'column' => 'idClan')),
      'idCovenant'   => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Covenant', 'column' => 'idCovenant')),
      'idAuspice'    => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Auspice', 'column' => 'idAuspice')),
      'idTribe'      => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'idLodge'      => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'idAdvantages' => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Advantages', 'column' => 'idAdvantages')),
      'xpTotal'      => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'xpActual'     => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'dtIni'        => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'dtEnd'        => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
    ));

    $this->widgetSchema->setNameFormat('character_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Character';
  }

  public function getFields()
  {
    return array(
      'idCharacter'  => 'Number',
      'idUser'       => 'ForeignKey',
      'idChronicle'  => 'ForeignKey',
      'idStatus'     => 'ForeignKey',
      'name'         => 'Text',
      'concept'      => 'Text',
      'idVirtue'     => 'ForeignKey',
      'idVice'       => 'ForeignKey',
      'faction'      => 'Text',
      'groupName'    => 'Text',
      'age'          => 'Number',
      'idBloodline'  => 'ForeignKey',
      'idClan'       => 'ForeignKey',
      'idCovenant'   => 'ForeignKey',
      'idAuspice'    => 'ForeignKey',
      'idTribe'      => 'Number',
      'idLodge'      => 'Number',
      'idAdvantages' => 'ForeignKey',
      'xpTotal'      => 'Number',
      'xpActual'     => 'Number',
      'dtIni'        => 'Date',
      'dtEnd'        => 'Date',
    );
  }
}
